package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Wuzishenqing;
import com.ruoyi.system.service.IWuzishenqingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物资申请Controller
 * 
 * @author ruoyi
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/system/wuzishenqing")
public class WuzishenqingController extends BaseController
{
    @Autowired
    private IWuzishenqingService wuzishenqingService;

    /**
     * 查询物资申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:wuzishenqing:list')")
    @GetMapping("/list")
    public TableDataInfo list(Wuzishenqing wuzishenqing)
    {
        startPage();
        List<Wuzishenqing> list = wuzishenqingService.selectWuzishenqingList(wuzishenqing);
        return getDataTable(list);
    }

    /**
     * 导出物资申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:wuzishenqing:export')")
    @Log(title = "物资申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Wuzishenqing wuzishenqing)
    {
        List<Wuzishenqing> list = wuzishenqingService.selectWuzishenqingList(wuzishenqing);
        ExcelUtil<Wuzishenqing> util = new ExcelUtil<Wuzishenqing>(Wuzishenqing.class);
        util.exportExcel(response, list, "物资申请数据");
    }

    /**
     * 获取物资申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wuzishenqing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wuzishenqingService.selectWuzishenqingById(id));
    }

    /**
     * 新增物资申请
     */
    @PreAuthorize("@ss.hasPermi('system:wuzishenqing:add')")
    @Log(title = "物资申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Wuzishenqing wuzishenqing)
    {
        return toAjax(wuzishenqingService.insertWuzishenqing(wuzishenqing));
    }

    /**
     * 修改物资申请
     */
    @PreAuthorize("@ss.hasPermi('system:wuzishenqing:edit')")
    @Log(title = "物资申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Wuzishenqing wuzishenqing)
    {
        return toAjax(wuzishenqingService.updateWuzishenqing(wuzishenqing));
    }

    /**
     * 删除物资申请
     */
    @PreAuthorize("@ss.hasPermi('system:wuzishenqing:remove')")
    @Log(title = "物资申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wuzishenqingService.deleteWuzishenqingByIds(ids));
    }
}
